#include "stdafx.h"

#include "input_manager.h"
//#include  "../shapes.h"
/*#include <windows.h>*/
#include "../renderer/renderer.h"

CInputManager* CInputManager::_inst = 0;

CInputManager::CInputManager() : _mouse(){}
CInputManager::CMouseInput::CMouseInput() : _vpID(0), _center_cln(), _center_scr(), mousePos(){}

int CInputManager::CMouseInput::listenResize(const SRect & rect)
{
	// Viewport was resized, we compute the new centroid, screenwise

	CMouseInput & mouse = CInputManager::getInstance()->getMouse();
	RECT rc;
	const HWND & hWnd = CRenderer::getHWND();
	HDC hDC = GetDC(hWnd);
	GetClientRect(hWnd, &rc);

	mouse.setScreenCenter(rect.w / 2, rect.h / 2);
	mouse.setClientCenter(rect.w / 2, rect.h / 2);

	ClientToScreen(hWnd, (LPPOINT)&mouse.getScreenCenter());

	return 0;
}

void CInputManager::CMouseInput::mouseMove(int dx, int dy)
{
	mousePos.set(static_cast<short>(dx), static_cast<short>(dy));
/*
	char buff[33];
	memset(buff, 0, sizeof(buff));


	_itoa(mousePos.d.x, buff, 10);
	int ss1 = strlen(buff);
	buff[ss1] = ',';
	buff[ss1 + 1] = ' ';
	buff[ss1 + 2] = 0;
	int ss2 = strlen(buff);

	_itoa(mousePos.d.y, buff + ss2, 10);


	RECT rc;
	const HDC hDC = CRenderer::getInstance()->getContext().getDC();
	FillRect(hDC, &rc, (HBRUSH)(COLOR_WINDOW + 1));
	GetClientRect(CRenderer::getInstance()->getHWND(), &rc);
	DrawTextA(hDC, buff, strlen(buff), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
*/
}